<?php
		include("./function.php");

       if($_GET["logout"] == "1"){
		   	  //echo "1";
			 $_SESSION["admin_login"] = false;
                $_SESSION["admin_member_id"] = "";
                $_SESSION["admin_user"] = ""; 
			header("Location: ./login_form.php");
		}else  if($_SESSION["admin_login"])
        {
			  //echo "2";
            header("Location: ./home.php");
        }
		//print_r($_POST);
        if($_POST)
        {  //echo "3";
            $user = cleanText(PLAIN,$_POST["user"]);
            $password = cleanText(PLAIN,$_POST["password"]);
            $sql = "select * from useradmin where u_user = '".$user."' and  u_pass = '".$password."' ";
            $result = Q2($sql);
            
            if(count($result) > 0)
            {
                $info = $result[0];
                $_SESSION["admin_login"] = true;
                $_SESSION["admin_member_id"] = $info[u_id];
                $_SESSION["admin_user"] = $info[u_user];  
                header("Location: ./home.php");
            }
            else
            {
				header("Location: ./login_form.php?err=1");
            }
        }
        
 
?>